package com.future.mayi.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.future.baselib.utils.CommonUtils;
import com.future.mayi.R;
import com.future.mayi.model.ConsignOrderGoodsModel;
import com.future.mayi.model.interfaces.SoldChangeListener;

/**
 * Created by 周大虎 on 2018/3/9.
 */

public class SoldChangeDialog extends Dialog {

    private SoldChangeListener listener;
    private ConsignOrderGoodsModel model;

    public SoldChangeDialog(@NonNull Context context) {
        super(context, R.style.dialog);
        setCancelable(false);
        init(context);
    }

    private void init(Context context) {
        View layout = LayoutInflater.from(context).inflate(R.layout.dialog_sold_change, null);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(CommonUtils.getScreenSize(context)[0] - CommonUtils.dip2px(context, 30), ViewGroup.LayoutParams.WRAP_CONTENT);
        setContentView(layout, params);
        findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        findViewById(R.id.ll_reduction).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener != null) listener.onReduction(model);
            }
        });
        findViewById(R.id.ll_recycle).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener != null) listener.onRecycle(model);
            }
        });
        findViewById(R.id.ll_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener != null) listener.onBack(model);
            }
        });

    }

    public void show(SoldChangeListener listener,ConsignOrderGoodsModel model) {
        this.listener = listener;
        this.model = model;
        super.show();
    }

}
